// src/store/index.js
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        token: null,
        user: null
    },
    mutations: {
        setToken(state, token) {
            state.token = token;
        },
        setUser(state, user) {
            state.user = user;
        }
    },
    actions: {
        saveToken({commit}, token) {
            commit('setToken', token);
        },
        saveUser({commit}, user) {
            commit('setUser', user);
        }
    },
    getters: {
        getToken: state => state.token,
        getUser: state => state.user,
    }
});
